package com.lhy.controller;

import com.lhy.domain.CostSettleDetails;
import com.lhy.service.CostSettleDetailsService;
import com.lhy.utils.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 汪
 */
@Controller
public class CostCommitController {
    @Autowired
    CostSettleDetailsService costSettleDetailsService;
    @RequestMapping("/showAllCost")
    public String showAllCos(HttpServletRequest req, HttpServletResponse resp){
        List<CostSettleDetails> costSettleDetailses=costSettleDetailsService.showAllCostSettle();
        HttpSession session = req.getSession();
        session.setAttribute("costSettleDetailses",costSettleDetailses);
        return "settle";
    }
    @RequestMapping("/findSomeCostCommit")
    public String findSomeCostCommit(CostSettleDetails costSettleDetails, Pagination<CostSettleDetails> page, HttpServletRequest req, HttpServletResponse resp){
        page.setQueryObject(costSettleDetails);
        costSettleDetailsService.findSomeCost(page);
        HttpSession session = req.getSession();
        session.setAttribute("costSettleDetailses",page);
        return "settle";
    }
    @RequestMapping("/deleteCost")
    public String deleteCost(HttpServletRequest req, HttpServletResponse resp){
        Integer id = Integer.parseInt(req.getParameter("id"));
        System.out.println(id);
        costSettleDetailsService.deleteCost(id);
        return "main";

    }
}
